package com.xmut.mall.order.vo;

import com.xmut.mall.order.entity.AfterSaleEntity;
import com.xmut.mall.order.myenum.AfterSaleStatusEnum;
import lombok.Data;

/**
 * 售后可操作类型
 */
@Data
public class AfterSaleAllowOperation {
    // 可以确认售后
    private Boolean confirm = false;

    // 可以回寄物流
    private Boolean returnGoods = false;

    // 可以收货
    private Boolean rog = false;

    // 可以退款
    private Boolean refund = false;

    // 买家确认收货
    private Boolean buyerConfirm;

    // 可以取消
    private Boolean cancel;

    /**
     * 根据各种状态构建对象
     *
     * @param afterSale
     */
    public AfterSaleAllowOperation(AfterSaleEntity afterSale) {
        //售后单状态
        String serviceStatus = afterSale.getServiceStatus();

        //新提交售后
        if (serviceStatus.equals(AfterSaleStatusEnum.APPLY.name())) {
            confirm = true;
        }

        //待确认收货
        if (serviceStatus.equals(AfterSaleStatusEnum.BUYER_RETURN.name())) {
            rog = true;
        }

        //待平台线下退款
        if (serviceStatus.equals(AfterSaleStatusEnum.WAIT_REFUND.name())) {
            refund = true;
        }

        //待平台线下退款
        if (serviceStatus.equals(AfterSaleStatusEnum.WAIT_REFUND.name())) {
            refund = true;
        }

        //待平台线下退款
        if (serviceStatus.equals(AfterSaleStatusEnum.APPLY.name())
                ||serviceStatus.equals(AfterSaleStatusEnum.PASS.name())) {
            cancel = true;
        }


    }
}
